package com.bjpowernode;


import com.bjpowernode.ba02.School;
import com.bjpowernode.ba02.Student;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;

public class MyTest02 {

    //
    @Test
    public void test01(){
        String configure="ba01/applicationContext.xml";

        ApplicationContext applicationContext=new ClassPathXmlApplicationContext(configure);

        //获取容器中的对象
        Student student=(Student) applicationContext.getBean("myStudent");
        System.out.println(student);



    }

    //一般方法
    @Test
    public void test02(){
        Student student=new Student();
        student.setName("lhl");
        student.setAge(21);

        School school=new School();
        school.setName("神");
        school.setAddress("陕西");
        student.setSchool(school);

        System.out.println(student);
    }



    //引用类型赋值
    @Test
    public void test03(){
        String configure="ba02/applicationContext.xml";

        ApplicationContext applicationContext=new ClassPathXmlApplicationContext(configure);

       Student student=(Student) applicationContext.getBean("mystudent");

        System.out.println(student);

    }
}
